package com.huike.clues.utils;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.huike.clues.domain.dto.ImportResultDTO;
import com.huike.clues.domain.vo.TbClueExcelVo;
import com.huike.clues.service.ITbClueService;

/**
 * 监听器不可以加入IOC容器,因为是单例的
 */
public class ExcelListener extends AnalysisEventListener<TbClueExcelVo> {

    public ITbClueService clueService;

    private ImportResultDTO resultDTO;

    public ExcelListener(ITbClueService clueService) {
        this.clueService = clueService;
        this.resultDTO = new ImportResultDTO();
    }

    /**
     * 每解析一行数据都要执行一次
     *
     * @param tbClueExcelVo   Excel表实体类
     * @param analysisContext
     */
    @Override
    public void invoke(TbClueExcelVo tbClueExcelVo, AnalysisContext analysisContext) {

    }

    /**
     * 当所有数据都解析完成后会执行
     *
     * @param analysisContext
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }

    /**
     * 返回结果对象
     * @return
     */
    public ImportResultDTO getResult() {
        return resultDTO;
    }
}
